import '../font/sym.css'

class SVGIcon extends React.Component{
    constructor(props){
        super(props);
        if(props.size == 'lg')
            this.size = 30;
        else if(props.size == 'md')
            this.size = 23;
        else if(props.size == 'sm')
            this.size = 18;
        else if(props.size == 'xs')
            this.size = 14;
        else
            this.size = props.size;

        this.style = this.props.style?this.props.style:{};
        this.style.fontSize = this.size;
    }
    onClick(){
        if(this.props.onClick)
            this.props.onClick();
    }
    render(){
        return (
            <svg className="icon" aria-hidden="true" style={this.style} onClick={()=>this.onClick()}>
                <use xlinkHref={this.props.local?"#"+this.props.type:"#icon-"+this.props.type}></use>
            </svg>
        )
    }
}

export default SVGIcon;